﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Wicture.QPZS.EPC.API.Domain.Entities;
using Wicture.QPZS.EPC.API.Repository;

namespace Wicture.QPZS.EPC.API.Throtteds
{
    public class CostLogThrottled : IThrottled
    {
        private readonly IServiceRepository _serviceRepository;

        public CostLogThrottled(IServiceRepository serviceRepository)
        {
            _serviceRepository = serviceRepository;
        }

        public decimal Order => 3;

        public List<ServicePackageType> ServicePackageTypes => new List<ServicePackageType> {
            ServicePackageType.包时,
            ServicePackageType.包次,
            ServicePackageType.计价
        };

        public void Invoke(ThrottlingContext context)
        {
            _serviceRepository.AddCostLog(context.AccountId, context.AccountPackage.Id, context.ApiName, context.QueryString, context.Cost);
        }
    }
}
